package unit_5;
import java.util.Arrays;
public class Demo06 {
    public static int[] sumArray(int[] a, int[] b){
        int size = Math.max(a.length, b.length);
        int[] result = new int[size];
        a = Arrays.copyOf(a, size);
        b = Arrays.copyOf(b, size);
        for(int i = 0; i < size; i++){
            result[i] = a[i] + b[i];
        }
        return result;
    }
    public static void main(String[] args) {
        int[] a = {1, 2, 4};
        int[] b = {2, 4, 6, 8};
        int[] result = sumArray(a, b);
        for(int i : result){
            System.out.print(i + " ");
        }
    }
}
